package by.yakusekmaxim.bookgid.webapp.page.utils.renderer;

import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.ResourceModel;

import by.yakusekmaxim.bookgid.datamodel.enums.UserRole;

public class UserRoleRenderer implements IChoiceRenderer<UserRole> {

	public static UserRoleRenderer INSTANCE = new UserRoleRenderer();
	
	@Override
	public Object getDisplayValue(UserRole object) {
		if (object == UserRole.userrole_admin) {
			return new ResourceModel("p.admin.user.role.admin").getObject();
		}

		if (object == UserRole.userrole_editor) {
			return new ResourceModel("p.admin.user.role.editor").getObject();
		}

		if (object == UserRole.userrole_user) {
			return new ResourceModel("p.admin.user.role.user").getObject();
		}
		return null;
	}

	@Override
	public String getIdValue(UserRole object, int index) {
		
		return object.name();
	}

}
